<!--基本html代码区域-->
<template>
  <div class="firstdemo">
    <el-header>
        <el-col :span="24" style="text-align: center">
          onebank后台管理系统
        </el-col>
    </el-header>
      <el-form ref="form" :model="form" label-width="100px">
          <el-row type="flex" justify="center">
              <el-col :span="8">
                  <el-form-item label="账户：" prop="name">
                      <el-input style="width:300px" v-model="form.userName" size="small"></el-input>
                  </el-form-item>
              </el-col>
          </el-row>
          <el-row type="flex" justify="center">
              <el-col :span="8">
                  <el-form-item label="密码：" prop="password">
                      <el-input style="width:300px" v-model="form.password" size="small" show-password></el-input>
                  </el-form-item>
              </el-col>
          </el-row>
          <el-row type="flex" justify="center">
              <el-col :span="8">
                  <el-form-item>
                      <el-button style="width:300px" type="primary" @click="submit">登录</el-button>
                  </el-form-item>
              </el-col>
          </el-row>
      </el-form>
         
  </div>
</template>
 
<script>
import { validUserName } from "@/utils/validate";
import { Login } from "@/api";
export default {
  name: 'firstdemo',
  data () {
    return {
        form:{
            userName:'',
            password:'',
        },
      
    }
  },
  methods:{
      submit() {
        if (!validUserName(this.name)) {
          return this.$message.error('无效的登录名');
        }
        // 登录接口
        Login({
          userName: this.userName,
          password: this.password   
        }).then(res => {
          if (res.errorCode === "0") {
            this.$router.push({ path: "/home/mngSite" });
          } 
        });
      }
  }
}
</script>
<style scoped>
 div{
   text-align: center
 }
</style>